package com.kpmg.questionnaire.repository;

import com.kpmg.questionnaire.model.AnswerEntity;
import com.kpmg.questionnaire.model.QuestionEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by xionghao on 2016/11/9.
 */
@Repository // 添加注解
public interface AnswerRepository extends JpaRepository<AnswerEntity, Integer> {
    @Modifying // 说明该方法是修改操作
    @Transactional // 说明该方法是事务性操作
    // 定义查询
    // @Param注解用于提取参数
    @Query("update AnswerEntity us set us.content=:qContent, us.type=:qType, us.userId=:qUserId, us.question=:qQuestion, us.title=:qTitle, us.results=:qResults, us.createDate=:qCreateDate where us.id=:qId")
    public void updateItem(@Param("qContent") String content,
                           @Param("qType") String type,
                           @Param("qUserId") String userId,
                           @Param("qQuestion") String question,
                           @Param("qTitle") String title,
                           @Param("qResults") String results,
                           @Param("qCreateDate") String createDate,
                           @Param("qId") Integer id);

}
